//
 

#import "NT_SearchView.h"

@implementation NT_SearchView

- (instancetype)initWithFrame:(CGRect)frame {
    if ([super initWithFrame:frame]) {
        
        [self setUpView];
    }
    return self;
}

//MARK:
- (void)setUpView {
    //
    self.searchView = [[UITextField alloc]init];
    self.searchView.textColor = [UIColor lightGrayColor];
    self.searchView.placeholder = @"笔记搜索";
    self.searchView.font = [UIFont systemFontOfSize:15];
    self.searchView.backgroundColor = [UIColor whiteColor];
    self.searchView.delegate = self;
    [self.searchView addTarget:self action:@selector(Action:) forControlEvents:UIControlEventEditingChanged];
    self.searchView.layer.cornerRadius = 2;
    [self addSubview:self.searchView];
    [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(5);
        make.left.mas_offset(20);
        make.right.mas_offset(-20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-5);
    }];
}
//
- (void)Action:(UITextField*)obj {
    
    if ([self.delegate respondsToSelector:@selector(getTextFieldText:)]) {
        [self.delegate getTextFieldText:obj.text];
    }
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSLog(@"7");// 点击键盘的‘换行’会调用
  
    [textField resignFirstResponder];
    
    return YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
